package com.mju.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mju.pojo.Vip;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;

@Mapper
public interface VipDao extends BaseMapper<Vip> {

    /**
     * 根据uid查询VIP信息
     * @param uid
     * @return
     */
    @Select("SELECT * from t_vip where uid=#{uid}")
    Vip getByUid(Integer uid);

    /**
     * 修改VIP状态
     * @param uid
     * @param status
     */
    @Update("update t_vip set status=#{status} where uid = #{uid}")
    Integer updateVIPStatus(@Param("uid") Integer uid,@Param("status") Boolean status);

    /**
     * 根据uid查询VIP是否有效
     * @param uid
     * @return
     */
    @Select("select * from t_vip where uid=#{uid} and status=0")
    Vip queryVipByUid(Integer uid);

    @Update("update t_vip set end_time=#{endTime} where uid=#{uid}")
    Integer updateVIPEndTime(@Param("uid") Integer uid, @Param("endTime")Date endTime);
}
